package com.biqee.action.homepage;

import java.util.List;

import com.biqee.action.base.BaseAction;
import com.biqee.model.common.BqTuanStatus;
import com.biqee.model.common.PageInfoObject;
import com.biqee.model.db.BqTuan;
import com.biqee.service.bq.BqTuanService;

/*
 * Biqee 首页Action
 */
public class HomepageAction extends BaseAction {

	private static final long serialVersionUID = 8004145979374091521L;

	private static final int DEFAULT_TOP_NUMBER = 6;
	
	private static final int DEFAULT_MORE_NUMBER = 12;
	
	private BqTuanService bqTuanService;

	public void setBqTuanService(BqTuanService bqTuanService) {
		this.bqTuanService = bqTuanService;
	}

	private PageInfoObject page = new PageInfoObject();
	{
		page.setLimit(DEFAULT_MORE_NUMBER);
	}
	
	public PageInfoObject getPage() {
		return page;
	}

	public void setPage(PageInfoObject page) {
		this.page = page;
	}

	/**
	 * 传递到首页的列表：评价结果为划算的列表
	 */
	private List<BqTuan> goodList;

	/**
	 * 传递到首页的列表：评价结果为一般的列表
	 */
	private List<BqTuan> commonList;
	
	/**
	 * 传递到首页的列表：评价结果为不划算的列表
	 */
	private List<BqTuan> badList;
	
	public List<BqTuan> getGoodList() {
		return goodList;
	}

	public void setGoodList(List<BqTuan> goodList) {
		this.goodList = goodList;
	}

	public List<BqTuan> getCommonList() {
		return commonList;
	}

	public void setCommonList(List<BqTuan> commonList) {
		this.commonList = commonList;
	}

	public List<BqTuan> getBadList() {
		return badList;
	}

	public void setBadList(List<BqTuan> badList) {
		this.badList = badList;
	}

	public String index() {
		goodList = bqTuanService.listGoodTuanOfToday(0, DEFAULT_TOP_NUMBER);
		commonList = bqTuanService.listCommonTuanOfToday(0, DEFAULT_TOP_NUMBER);
		badList = bqTuanService.listBadTuanOfToday(0, DEFAULT_TOP_NUMBER);
		
		return "index"; 
	}
	
	public String mg() {

		goodList = bqTuanService.listGoodTuanOfToday(page.getStart(), DEFAULT_MORE_NUMBER);
		
		int count = bqTuanService.countStatus(BqTuanStatus.GOOD);
		page.setCount(count);
		page.setLimit(DEFAULT_MORE_NUMBER);
		
		return "moreGood";
	}
	
	public String mc() {
		commonList = bqTuanService.listCommonTuanOfToday(page.getStart(), DEFAULT_MORE_NUMBER);
		
		int count = bqTuanService.countStatus(BqTuanStatus.COMMON);
		page.setCount(count);
		page.setLimit(DEFAULT_MORE_NUMBER);
		
		return "moreCommon";
	}
	
	public String mb() {
		badList = bqTuanService.listBadTuanOfToday(page.getStart(), DEFAULT_MORE_NUMBER);
		
		int count = bqTuanService.countStatus(BqTuanStatus.BAD);
		page.setCount(count);
		page.setLimit(DEFAULT_MORE_NUMBER);
		
		return "moreBad";
	}
}
